//
//  DatePicker.swift
//  sdyd
//
//  Created by sunlubo on 16/7/19.
//  Copyright © 2016年 milanosoft. All rights reserved.
//

import UIKit

/// 日期选择器
public final class DatePicker: PopupController {
    public var datePicker: UIDatePicker!
    
    public var datePickerMode = UIDatePickerMode.date
    public var minuteInterval = 1
    public var minimumDate: Date?
    public var maximumDate: Date?

    public override func setupContentView() {
        super.setupContentView()
        
        title = "选择日期"
        contentHeight = 250
        leftButton.setImage(nil, for: .normal)
        leftButton.setTitle("取消", for: .normal)

        datePicker = UIDatePicker()
        datePicker.datePickerMode = self.datePickerMode
        datePicker.minuteInterval = self.minuteInterval
        datePicker.minimumDate = self.minimumDate
        datePicker.maximumDate = self.maximumDate
        contentView.addSubview(datePicker)
        datePicker.snp.makeConstraints { $0.edges.equalToSuperview() }
    }

    public override func handleEventForRightButton() {
        self.result = datePicker.date
    }
}
